/**
 * 详情对话框
 */
var HxOrderPutInfoDlg = {
    data: {
        customerId: "",
        customerName: "",
        orderState: "",
        yuyueTime: "",
        orderPutNumber: "",
        orderType: "",
        getUnitId: "",
        getUnit: "",
        getWarehouseId: "",
        getWarehouse: "",
        setUnitId: "",
        setUnit: "",
        goodsNum: "",
        putNum: "",
        putVolume: "",
        createUserName: "",
        submitUserName: "",
        revokeUserName: "",
        submitTime: "",
        createTime: "",
        revokeTime: "",
        notes: "",
        v1: "",
        v2: "",
        v3: "",
        v4: "",
        v5: "",
        v6: "",
        deptId: "",
        deliverId: ""
    }
};
var BasicPutgoodsInfoDlg = {
    data: {
		id:"",
		dictId:"",
        putgoodsCustomerId: "",
        putgoodsOperateName: "",
        putgoodsName: "",
		unitNumber:"",
		unitType:""
    }
};
layui.use(['form', 'admin', 'ax','laydate'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var laydate = layui.laydate;

    laydate.render({
    	elem:'#yuyueTime'
    });

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //获取详情信息，填充表单
    var ajax = new $ax(Feng.ctxPath + "/hxOrderPut/detail?id=" + Feng.getUrlParam("id"));
    var result = ajax.start();
    form.val('hxOrderPutForm', result.data);

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/hxOrderPut/editItem", function (data) {
        	if (data.success) {
                Feng.success("更新成功！");
                window.location.href = Feng.ctxPath + '/hxOrderPut/toReturnGoods'
			} else {
                Feng.error("更新失败！"+data.message);
			}
        }, function (data) {
            Feng.error("更新失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });
    
    $('#choiceSetUnit').click(function () {
        layer.open({
            type: 2,
            title: '选择发货客户',
            area: ['1000px', '500px'],
            content: Feng.ctxPath + '/basicPutgoods/tochoiceBasicPutgoods_hx',
            end: function () {
                $("#setUnitId").val(BasicPutgoodsInfoDlg.data.id);
                $("#setUnit").val(BasicPutgoodsInfoDlg.data.putgoodsName);
            }
        });
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/hxOrderPut/toReturnGoods'
    });

});